<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="邵铭">
    <title></title>
    <style>
    #clock{
			width: 300px;
			margin: 0 auto;
			background-color: #333;
			padding: 5px;
			color: white;
			text-align: center;
		}
		span{
			display: inline-block;
			padding: 0 10px;
			margin: 0 10px;
			border: 2px solid #999;
			background-color: #fff;
			color: #000;
		}
        button{
            margin: 10px;
        }
    </style>
</head>
<body>
<div id="clock">
		<p>
            <span>01</span>分
            <span>10</span>秒
        </p>
        <button type="button" onclick="start()">开始倒计时</button>
	</div>
</body>
</html>
<script>
   
var spans=document.querySelectorAll('span');
var button=document.querySelector('button');
 
   function start(){
        if(spans[1].innerHTML > 0){
            spans[1].innerHTML--;
            
        }else if(spans[0].innerHTML > 0){
            spans[0].innerHTML--;
            spans[1].innerHTML = 59;
        }else{
            clearInterval(timer);
        }
    }
    var timer;
    var kaishi = true;
    button.onclick = function(){
        if(kaishi==true){
            timer = setInterval(start,1000);
            button.innerHTML = '暂停';
            kaishi = false;
        }
        else{
            clearInterval(timer);
            button.innerHTML = '开始';
            kaishi = true;
        }
        
    }


</script>